<template>
  <div class="over-center-ellipsis">
    <div class="line">
      <div class="info">这段文本很长，需要你让其超出隐藏才会展示title哦</div>
      <div
        class="title"
        title="这段文本很长，需要你让其超出隐藏才会展示title哦"
      >
        这段文本很长，需要你让其超出隐藏才会展示title哦
      </div>
    </div>
  </div>
</template>
<script setup></script>
<style lang="scss" scoped>
.over-center-ellipsis {
  border-radius: 8px;
  resize: horizontal;
  overflow: hidden;
  width: 500px;
  font-size: 14px;
  padding: 15px;
  margin: 50px auto;
  line-height: 2;
  box-shadow: 20px 20px 60px #bebebe, -20px -20px 60px #ffffff;
  .line {
    padding: 0 10px;
    margin: 5px 0;
    height: 2em;
    overflow: hidden;
    position: relative;
    text-align: justify;
    background-color: #fff;
    .info {
      max-height: 4em;
    }
    .title {
      position: relative;
      top: -4.1em;
      height: 2em;
      overflow: hidden;
      background: inherit;
      &::before {
        content: attr(title);
        width: 50%;
        float: right;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        direction: rtl;
      }
    }
  }
}
</style>
